/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : ShapeDisplayHandler.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 23, 2008       Raghu Sarraff			       Created
 */
package lwf.handler.shape;

import java.util.ArrayList;
import java.util.List;

import lwf.handler.english.WordHandler;
import lwf.handler.entities.shape.ShapeData;
import net.lwf.common.constant.ICommonConstant;
import net.lwf.handler.constant.IHandlerConstant;
import net.lwf.handler.util.ImageHtml;
import net.lwf.number.util.RandomNumberGenerator;

/**
 * Type the class description here
 *  
 */
public class ShapeDisplayHandler extends WordHandler {
	
	public ShapeDisplayHandler(int start, int end, List lstData) {
		init(start, end, lstData);
	}
	
	private void init(int start, int end, List lstData) {
		setDisplayData(start, end, lstData);
		setShowbuttontop(true);
	}
	
    protected String processRowData(Object obj) {
    	ShapeData shape = (ShapeData) obj;
    	StringBuffer sbShape = new StringBuffer();
    	sbShape.append("<table border=\"0\" width=\"100%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">");
		    sbShape.append("<tr>");
	   			sbShape.append("<td align=\"center\" >");
	   				sbShape.append(ImageHtml.getWordImage(shape.getName(), shape.getColorcode()));
	   			sbShape.append("</td>");
		    sbShape.append("</tr>");
		    sbShape.append("<tr>");
	    		sbShape.append("<td>&nbsp;</td>");
	    	sbShape.append("</tr>");
		    sbShape.append("<tr>");
	   			sbShape.append("<td class=\"tableheadercenter\">");
	   				sbShape.append("This is a " + shape.getName());
	   			sbShape.append("</td>");
	        sbShape.append("</tr>");
		    sbShape.append("<tr>");
    			sbShape.append("<td>&nbsp;</td>");
    	    sbShape.append("</tr>");
		    sbShape.append("<tr>");
		    	sbShape.append("<td>&nbsp;</td>");
	        sbShape.append("</tr>");
		    sbShape.append("<tr>");
	    		sbShape.append("<td class=\"questionmedium\" >What is a " + shape.getName() + "?</td>");
	    	sbShape.append("</tr>");
		    sbShape.append("<tr>");
	    		sbShape.append("<td>&nbsp;</td>");
	    	sbShape.append("</tr>");
		    sbShape.append("<tr>");
	   			sbShape.append("<td class=\"tablesubheader\" >");
	   				sbShape.append(shape.getDescription());
	   			sbShape.append("</td>");
   			sbShape.append("</tr>");
		    sbShape.append("<tr>");
	    		sbShape.append("<td>&nbsp;</td>");
	    	sbShape.append("</tr>");
		    sbShape.append("<tr>");
	    		sbShape.append("<td>&nbsp;</td>");
	    	sbShape.append("</tr>");
		    sbShape.append("<tr>");
    			sbShape.append("<td>&nbsp;</td>");
    	    sbShape.append("</tr>");
	    	sbShape.append("<tr>");
    			sbShape.append("<td class=\"questionmedium\" >Can you identify some " + shape.getName() + " shaped objects?</td>");
    	    sbShape.append("</tr>");
		    sbShape.append("<tr>");
    			sbShape.append("<td>&nbsp;</td>");
    	    sbShape.append("</tr>");
    	    /*
    		sbShape.append("<tr>");
	        	sbShape.append("<td>");
   					sbShape.append("This is a " + shape.getQuestion());
   				sbShape.append("</td>");
			sbShape.append("</tr>");
			*/
        sbShape.append("</table>");
        return sbShape.toString();
    }
    
    public static List generateShapes() {
    	List lstData = new ArrayList();
    	for(int i=0; i<IHandlerConstant.AVAILABLE_SHAPES; i++) {
    		int color = RandomNumberGenerator.generate(1, ICommonConstant.AVAILABLE_COLORS);
    		ShapeData data = new ShapeData(i+1, color);
    		lstData.add(data);
    	}
    	return lstData;
    }

}

